import Http from "./utils/Http";
import Cache from "./utils/Cache"
import url from "./utils/url"
const http = new Http;
//app.js
App({
  onLaunch() {
    if(!Cache.has("openid")){
      wx.login({
        timeout:10000,
        success: (result)=>{
          let code = result.code;
          console.log(code);
          http.httpRequest({
              url:url.wxlogin,
              data:{ code },
              method:"POST"
          }).then(ret => {
            let openid = ret.data.data.openid;
            let id = ret.data.data.id;
            Cache.forever("openid",openid);
            Cache.forever("id",id);
            console.log(ret);
          })
        },
        fail: ()=>{},
        complete: ()=>{}
      });

    }
  }
})